package jjn.round2;

/**
 * @author Jiang Jining
 * @since 2023-05-18 22:47
 */
public class Offer66_ConstructArr {
    public int[] constructArr(int[] a) {
        int[] result = new int[a.length];
        int ans = 1;
        for (int i = 0; i < a.length; i++) {
            result[i] = ans;
            ans *= a[i];
        }
        ans = 1;
        for (int i = a.length - 1; i >= 0; i--) {
            result[i] *= ans;
            ans *= a[i];
        }
        return result;
    }
}
